{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-03-09T13:48:54.364955Z",
     "start_time": "2020-03-09T13:48:54.360254Z"
    }
   },
   "outputs": [],
   "source": [
    "import requests\n",
    "import json\n",
    "import ast\n",
    "import demjson"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-03-09T13:48:55.587688Z",
     "start_time": "2020-03-09T13:48:55.583700Z"
    }
   },
   "outputs": [],
   "source": [
    "def get_industry(industry_url):\n",
    "    response = requests.get(industry_url)\n",
    "    response.encoding = response.apparent_encoding\n",
    "    json_str=response.text[response.text.index('{'):]\n",
    "    return json.loads(json_str)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-03-09T13:48:57.854850Z",
     "start_time": "2020-03-09T13:48:57.848867Z"
    }
   },
   "outputs": [],
   "source": [
    "def get_code_name(industry_json):\n",
    "    result=[]\n",
    "    \n",
    "    for key in industry_json:\n",
    "        result.append((key, industry_json[key].split(',')[1]))\n",
    "    \n",
    "    return result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-03-09T13:49:00.080275Z",
     "start_time": "2020-03-09T13:48:59.908515Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[('new_blhy', '玻璃行业'),\n",
       " ('new_cbzz', '船舶制造'),\n",
       " ('new_cmyl', '传媒娱乐'),\n",
       " ('new_dlhy', '电力行业'),\n",
       " ('new_dqhy', '电器行业'),\n",
       " ('new_dzqj', '电子器件'),\n",
       " ('new_dzxx', '电子信息'),\n",
       " ('new_fdc', '房地产'),\n",
       " ('new_fdsb', '发电设备'),\n",
       " ('new_fjzz', '飞机制造'),\n",
       " ('new_fzhy', '纺织行业'),\n",
       " ('new_fzjx', '纺织机械'),\n",
       " ('new_fzxl', '服装鞋类'),\n",
       " ('new_glql', '公路桥梁'),\n",
       " ('new_gsgq', '供水供气'),\n",
       " ('new_gthy', '钢铁行业'),\n",
       " ('new_hbhy', '环保行业'),\n",
       " ('new_hghy', '化工行业'),\n",
       " ('new_hqhy', '化纤行业'),\n",
       " ('new_jdhy', '家电行业'),\n",
       " ('new_jdly', '酒店旅游'),\n",
       " ('new_jjhy', '家具行业'),\n",
       " ('new_jrhy', '金融行业'),\n",
       " ('new_jtys', '交通运输'),\n",
       " ('new_jxhy', '机械行业'),\n",
       " ('new_jzjc', '建筑建材'),\n",
       " ('new_kfq', '开发区'),\n",
       " ('new_ljhy', '酿酒行业'),\n",
       " ('new_mtc', '摩托车'),\n",
       " ('new_mthy', '煤炭行业'),\n",
       " ('new_nlmy', '农林牧渔'),\n",
       " ('new_nyhf', '农药化肥'),\n",
       " ('new_qczz', '汽车制造'),\n",
       " ('new_qtxy', '其它行业'),\n",
       " ('new_slzp', '塑料制品'),\n",
       " ('new_snhy', '水泥行业'),\n",
       " ('new_sphy', '食品行业'),\n",
       " ('new_stock', '次新股'),\n",
       " ('new_swzz', '生物制药'),\n",
       " ('new_sybh', '商业百货'),\n",
       " ('new_syhy', '石油行业'),\n",
       " ('new_tchy', '陶瓷行业'),\n",
       " ('new_wzwm', '物资外贸'),\n",
       " ('new_ylqx', '医疗器械'),\n",
       " ('new_yqyb', '仪器仪表'),\n",
       " ('new_ysbz', '印刷包装'),\n",
       " ('new_ysjs', '有色金属'),\n",
       " ('new_zhhy', '综合行业'),\n",
       " ('new_zzhy', '造纸行业')]"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sina_industry_url='http://vip.stock.finance.sina.com.cn/q/view/newSinaHy.php'\n",
    "json_obj = get_industry(sina_industry_url)\n",
    "get_code_name(json_obj)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-03-08T18:28:29.788427Z",
     "start_time": "2020-03-08T18:28:29.784438Z"
    }
   },
   "outputs": [],
   "source": [
    "concept_industry_url='http://money.finance.sina.com.cn/q/view/newFLJK.php?param=class'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-03-08T18:28:30.243930Z",
     "start_time": "2020-03-08T18:28:29.790424Z"
    },
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "get_industry(concept_industry_url)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-03-08T18:31:18.206979Z",
     "start_time": "2020-03-08T18:31:17.638407Z"
    }
   },
   "outputs": [],
   "source": [
    "area_industry_url='http://money.finance.sina.com.cn/q/view/newFLJK.php?param=area'\n",
    "get_industry(area_industry_url)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-03-08T18:31:24.350642Z",
     "start_time": "2020-03-08T18:31:22.250568Z"
    }
   },
   "outputs": [],
   "source": [
    "industry_url='http://money.finance.sina.com.cn/q/view/newFLJK.php?param=industry'\n",
    "get_industry(industry_url)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-03-08T18:31:29.335252Z",
     "start_time": "2020-03-08T18:31:29.041656Z"
    },
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "qmx_industry_url='http://biz.finance.sina.com.cn/hq/qmxIndustryHq.php'\n",
    "get_industry(industry_url)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-03-09T13:47:24.260132Z",
     "start_time": "2020-03-09T13:47:24.050017Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'[{symbol:\"sh600050\",code:\"600050\",name:\"中国联通\",trade:\"5.640\",pricechange:\"-0.080\",changepercent:\"-1.399\",buy:\"5.640\",sell:\"5.650\",settlement:\"5.720\",open:\"5.640\",high:\"5.820\",low:\"5.610\",volume:225411130,amount:1283193141,ticktime:\"15:00:00\",per:42.695,pb:1.225,mktcap:17498386.335468,nmc:11954880.36678,turnoverratio:1.06343},{symbol:\"sh600105\",code:\"600105\",name:\"永鼎股份\",trade:\"5.110\",pricechange:\"0.030\",changepercent:\"0.591\",buy:\"5.110\",sell:\"5.120\",settlement:\"5.080\",open:\"4.960\",high:\"5.370\",low:\"4.900\",volume:77754625,amount:401528187,ticktime:\"15:00:00\",per:31.938,pb:2.295,mktcap:636423.6214,nmc:632777.61085,turnoverratio:6.27908},{symbol:\"sh600198\",code:\"600198\",name:\"大唐电信\",trade:\"10.750\",pricechange:\"0.350\",changepercent:\"3.365\",buy:\"10.740\",sell:\"10.750\",settlement:\"10.400\",open:\"10.140\",high:\"11.000\",low:\"10.110\",volume:48250627,amount:513649016,ticktime:\"15:00:00\",per:16.36,pb:-26.862,mktcap:948266.6074,nmc:946488.840125,turnoverratio:5.48019},{symbol:\"sh600289\",code:\"600289\",name:\"*ST信通\",trade:\"5.120\",pricechange:\"0.240\",changepercent:\"4.918\",buy:\"5.120\",sell:\"0.000\",settlement:\"4.880\",open:\"5.120\",high:\"5.120\",low:\"5.120\",volume:450163,amount:2304835,ticktime:\"15:00:00\",per:-2.191,pb:-3.435,mktcap:323098.659328,nmc:289752.414208,turnoverratio:0.07954},{symbol:\"sh600345\",code:\"600345\",name:\"长江通信\",trade:\"23.820\",pricechange:\"1.730\",changepercent:\"7.832\",buy:\"23.810\",sell:\"23.820\",settlement:\"22.090\",open:\"21.900\",high:\"24.300\",low:\"21.660\",volume:23325948,amount:555740337,ticktime:\"15:00:00\",per:20.359,pb:2.44,mktcap:471636,nmc:471636,turnoverratio:11.78078},{symbol:\"sh600485\",code:\"600485\",name:\"*ST信威\",trade:\"1.800\",pricechange:\"0.010\",changepercent:\"0.559\",buy:\"1.800\",sell:\"1.810\",settlement:\"1.790\",open:\"1.710\",high:\"1.860\",low:\"1.710\",volume:137377512,amount:245407959,ticktime:\"15:00:00\",per:-1.818,pb:-0.604,mktcap:526273.70076,nmc:341100.00756,turnoverratio:7.24947},{symbol:\"sh600487\",code:\"600487\",name:\"亨通光电\",trade:\"17.780\",pricechange:\"-0.240\",changepercent:\"-1.332\",buy:\"17.770\",sell:\"17.780\",settlement:\"18.020\",open:\"17.630\",high:\"18.530\",low:\"17.510\",volume:82222594,amount:1481238155,ticktime:\"15:00:00\",per:13.368,pb:2.584,mktcap:3384767.325702,nmc:3307672.475828,turnoverratio:4.41978},{symbol:\"sh600498\",code:\"600498\",name:\"烽火通信\",trade:\"34.500\",pricechange:\"0.850\",changepercent:\"2.526\",buy:\"34.500\",sell:\"34.510\",settlement:\"33.650\",open:\"33.500\",high:\"36.300\",low:\"33.030\",volume:82189845,amount:2862511889,ticktime:\"15:00:00\",per:45.395,pb:3.942,mktcap:4039896.9873,nmc:3818940.23655,turnoverratio:7.42496},{symbol:\"sh600522\",code:\"600522\",name:\"中天科技\",trade:\"9.200\",pricechange:\"-0.050\",changepercent:\"-0.541\",buy:\"9.190\",sell:\"9.200\",settlement:\"9.250\",open:\"9.060\",high:\"9.530\",low:\"8.950\",volume:127103627,amount:1179893197,ticktime:\"15:00:00\",per:13.295,pb:1.406,mktcap:2820796.19256,nmc:2820796.19256,turnoverratio:4.14547},{symbol:\"sh600728\",code:\"600728\",name:\"佳都科技\",trade:\"10.000\",pricechange:\"-0.580\",changepercent:\"-5.482\",buy:\"9.990\",sell:\"10.000\",settlement:\"10.580\",open:\"10.310\",high:\"10.360\",low:\"9.980\",volume:76538379,amount:776254733,ticktime:\"15:00:00\",per:61.162,pb:3.519,mktcap:1670818.826,nmc:1637140.326,turnoverratio:4.67513},{symbol:\"sh600770\",code:\"600770\",name:\"综艺股份\",trade:\"5.250\",pricechange:\"-0.230\",changepercent:\"-4.197\",buy:\"5.250\",sell:\"5.260\",settlement:\"5.480\",open:\"5.420\",high:\"5.450\",low:\"5.230\",volume:15843571,amount:84517049,ticktime:\"15:00:00\",per:126.812,pb:1.965,mktcap:682500,nmc:682500,turnoverratio:1.21874},{symbol:\"sh603322\",code:\"603322\",name:\"超讯通信\",trade:\"21.850\",pricechange:\"1.990\",changepercent:\"10.020\",buy:\"21.850\",sell:\"0.000\",settlement:\"19.860\",open:\"19.900\",high:\"21.850\",low:\"19.870\",volume:11991998,amount:257205428,ticktime:\"15:00:00\",per:87.4,pb:7.957,mktcap:341996.2,nmc:341996.2,turnoverratio:7.66164},{symbol:\"sh603602\",code:\"603602\",name:\"纵横通信\",trade:\"27.050\",pricechange:\"1.610\",changepercent:\"6.329\",buy:\"27.050\",sell:\"27.060\",settlement:\"25.440\",open:\"25.420\",high:\"27.980\",low:\"25.100\",volume:23737795,amount:646911106,ticktime:\"15:00:00\",per:67.625,pb:6.154,mktcap:424144,nmc:251344.34233,turnoverratio:25.54692},{symbol:\"sz000063\",code:\"000063\",name:\"中兴通讯\",trade:\"51.010\",pricechange:\"0.150\",changepercent:\"0.295\",buy:\"51.010\",sell:\"51.020\",settlement:\"50.860\",open:\"50.000\",high:\"53.390\",low:\"49.700\",volume:156308142,amount:8079437696,ticktime:\"15:00:03\",per:-30.545,pb:7.764,mktcap:23511166.998394,nmc:17710845.28097,turnoverratio:4.50192},{symbol:\"sz002093\",code:\"002093\",name:\"国脉科技\",trade:\"8.780\",pricechange:\"0.230\",changepercent:\"2.690\",buy:\"8.770\",sell:\"8.780\",settlement:\"8.550\",open:\"8.500\",high:\"9.260\",low:\"8.420\",volume:56927853,amount:509275635,ticktime:\"15:00:03\",per:67.074,pb:2.67,mktcap:884585,nmc:880323.3197,turnoverratio:5.67776},{symbol:\"sz002104\",code:\"002104\",name:\"恒宝股份\",trade:\"7.640\",pricechange:\"-0.130\",changepercent:\"-1.673\",buy:\"7.640\",sell:\"7.650\",settlement:\"7.770\",open:\"7.680\",high:\"7.980\",low:\"7.620\",volume:24304271,amount:189226674,ticktime:\"15:00:03\",per:37.268,pb:2.792,mktcap:532447.914456,nmc:449230.417756,turnoverratio:4.13339},{symbol:\"sz002115\",code:\"002115\",name:\"三维通信\",trade:\"11.160\",pricechange:\"-0.320\",changepercent:\"-2.787\",buy:\"11.150\",sell:\"11.160\",settlement:\"11.480\",open:\"11.170\",high:\"11.760\",low:\"11.100\",volume:35275194,amount:402269446,ticktime:\"15:00:03\",per:27.998,pb:3.227,mktcap:802616.128164,nmc:592586.484984,turnoverratio:6.64327},{symbol:\"sz002148\",code:\"002148\",name:\"北纬科技\",trade:\"5.180\",pricechange:\"-0.120\",changepercent:\"-2.264\",buy:\"5.180\",sell:\"5.190\",settlement:\"5.300\",open:\"5.220\",high:\"5.440\",low:\"5.170\",volume:14339509,amount:76055622,ticktime:\"15:00:03\",per:74,pb:2.558,mktcap:293070.790586,nmc:229790.848168,turnoverratio:3.23245},{symbol:\"sz002194\",code:\"002194\",name:\"武汉凡谷\",trade:\"26.750\",pricechange:\"-0.010\",changepercent:\"-0.037\",buy:\"26.750\",sell:\"26.760\",settlement:\"26.760\",open:\"26.180\",high:\"28.180\",low:\"26.000\",volume:46912337,amount:1278974173,ticktime:\"15:00:03\",per:79.994,pb:8.77,mktcap:1510491.50635,nmc:994267.911825,turnoverratio:12.6214},{symbol:\"sz002261\",code:\"002261\",name:\"拓维信息\",trade:\"9.210\",pricechange:\"-0.820\",changepercent:\"-8.175\",buy:\"9.210\",sell:\"9.220\",settlement:\"10.030\",open:\"9.850\",high:\"9.980\",low:\"9.180\",volume:65727308,amount:626944405,ticktime:\"15:00:03\",per:-7.427,pb:3.973,mktcap:1013806.290954,nmc:809718.495096,turnoverratio:7.47604},{symbol:\"sz002281\",code:\"002281\",name:\"光迅科技\",trade:\"32.500\",pricechange:\"-0.450\",changepercent:\"-1.366\",buy:\"32.490\",sell:\"32.500\",settlement:\"32.950\",open:\"32.420\",high:\"34.520\",low:\"31.930\",volume:28077129,amount:935237415,ticktime:\"15:00:03\",per:61.321,pb:4.997,mktcap:2200353.7335,nmc:2058751.22375,turnoverratio:4.43233},{symbol:\"sz002313\",code:\"002313\",name:\"日海智能\",trade:\"22.090\",pricechange:\"0.460\",changepercent:\"2.127\",buy:\"22.090\",sell:\"22.100\",settlement:\"21.630\",open:\"21.420\",high:\"22.560\",low:\"21.060\",volume:13863915,amount:304290971,ticktime:\"15:00:03\",per:96.043,pb:3.275,mktcap:689208,nmc:687773.473191,turnoverratio:4.45283},{symbol:\"sz002316\",code:\"002316\",name:\"亚联发展\",trade:\"7.900\",pricechange:\"-0.510\",changepercent:\"-6.064\",buy:\"7.890\",sell:\"7.900\",settlement:\"8.410\",open:\"8.280\",high:\"8.580\",low:\"7.860\",volume:22474916,amount:184999538,ticktime:\"15:00:03\",per:31.053,pb:3.4,mktcap:310564.8,nmc:231796.77797,turnoverratio:7.65981},{symbol:\"sz002364\",code:\"002364\",name:\"中恒电气\",trade:\"12.800\",pricechange:\"-0.630\",changepercent:\"-4.691\",buy:\"12.800\",sell:\"12.810\",settlement:\"13.430\",open:\"12.780\",high:\"13.610\",low:\"12.780\",volume:21852031,amount:285397095,ticktime:\"15:00:03\",per:91.429,pb:3.401,mktcap:721363.1488,nmc:659511.98336,turnoverratio:4.24111},{symbol:\"sz002369\",code:\"002369\",name:\"卓翼科技\",trade:\"10.970\",pricechange:\"-0.290\",changepercent:\"-2.575\",buy:\"10.960\",sell:\"10.970\",settlement:\"11.260\",open:\"11.060\",high:\"11.640\",low:\"10.910\",volume:41331281,amount:466112739,ticktime:\"15:00:03\",per:-60.944,pb:3.196,mktcap:633963.654288,nmc:460308.368895,turnoverratio:9.85001},{symbol:\"sz002417\",code:\"002417\",name:\"深南股份\",trade:\"7.630\",pricechange:\"-0.450\",changepercent:\"-5.569\",buy:\"7.630\",sell:\"7.640\",settlement:\"8.080\",open:\"7.950\",high:\"8.040\",low:\"7.600\",volume:15746848,amount:122894087,ticktime:\"15:00:03\",per:-42.389,pb:9.06,mktcap:206010,nmc:175074.902821,turnoverratio:6.86269},{symbol:\"sz002446\",code:\"002446\",name:\"盛路通信\",trade:\"8.960\",pricechange:\"0.110\",changepercent:\"1.243\",buy:\"8.960\",sell:\"8.970\",settlement:\"8.850\",open:\"8.900\",high:\"9.340\",low:\"8.820\",volume:77494446,amount:705413571,ticktime:\"15:00:03\",per:56,pb:2.191,mktcap:803798.03392,nmc:555964.359552,turnoverratio:12.48911},{symbol:\"sz002491\",code:\"002491\",name:\"通鼎互联\",trade:\"6.500\",pricechange:\"-0.030\",changepercent:\"-0.459\",buy:\"6.500\",sell:\"6.510\",settlement:\"6.530\",open:\"6.490\",high:\"6.930\",low:\"6.410\",volume:41917885,amount:278763017,ticktime:\"15:00:03\",per:14.525,pb:1.601,mktcap:820009.5436,nmc:764730.44115,turnoverratio:3.56291},{symbol:\"sz002544\",code:\"002544\",name:\"杰赛科技\",trade:\"16.030\",pricechange:\"-0.590\",changepercent:\"-3.550\",buy:\"16.020\",sell:\"16.030\",settlement:\"16.620\",open:\"16.350\",high:\"17.050\",low:\"16.010\",volume:19471832,amount:321769291,ticktime:\"15:00:03\",per:801.5,pb:4.355,mktcap:915565.02366,nmc:821797.488967,turnoverratio:3.79818},{symbol:\"sz002881\",code:\"002881\",name:\"美格智能\",trade:\"26.940\",pricechange:\"0.270\",changepercent:\"1.012\",buy:\"26.940\",sell:\"26.950\",settlement:\"26.670\",open:\"26.200\",high:\"27.460\",low:\"25.920\",volume:6349578,amount:171433255,ticktime:\"15:00:03\",per:104.703,pb:9.046,mktcap:488527.266,nmc:122143.266,turnoverratio:14.00467},{symbol:\"sz300025\",code:\"300025\",name:\"华星创业\",trade:\"5.390\",pricechange:\"-0.040\",changepercent:\"-0.737\",buy:\"5.380\",sell:\"5.390\",settlement:\"5.430\",open:\"5.280\",high:\"5.750\",low:\"5.250\",volume:53814985,amount:296435717,ticktime:\"15:00:03\",per:211.373,pb:3.022,mktcap:230977.972918,nmc:215111.554966,turnoverratio:13.4843},{symbol:\"sz300038\",code:\"300038\",name:\"数知科技\",trade:\"10.320\",pricechange:\"-0.530\",changepercent:\"-4.885\",buy:\"10.310\",sell:\"10.320\",settlement:\"10.850\",open:\"10.600\",high:\"10.860\",low:\"10.260\",volume:37493417,amount:396016827,ticktime:\"15:00:03\",per:19.083,pb:1.1,mktcap:1209325.590936,nmc:831504.852192,turnoverratio:4.6534},{symbol:\"sz300047\",code:\"300047\",name:\"天源迪科\",trade:\"7.900\",pricechange:\"-0.420\",changepercent:\"-5.048\",buy:\"7.900\",sell:\"7.920\",settlement:\"8.320\",open:\"8.170\",high:\"8.260\",low:\"7.900\",volume:27245819,amount:220099377,ticktime:\"15:00:03\",per:14.63,pb:1.634,mktcap:503818.29088,nmc:391465.26192,turnoverratio:5.49837},{symbol:\"sz300050\",code:\"300050\",name:\"世纪鼎利\",trade:\"5.930\",pricechange:\"-0.100\",changepercent:\"-1.658\",buy:\"5.920\",sell:\"5.930\",settlement:\"6.030\",open:\"5.940\",high:\"6.280\",low:\"5.680\",volume:38963937,amount:237464142,ticktime:\"15:00:03\",per:59.3,pb:1.121,mktcap:338956.853774,nmc:225788.447355,turnoverratio:10.2333},{symbol:\"sz300068\",code:\"300068\",name:\"南都电源\",trade:\"12.300\",pricechange:\"-0.390\",changepercent:\"-3.073\",buy:\"12.290\",sell:\"12.300\",settlement:\"12.690\",open:\"12.550\",high:\"12.840\",low:\"12.300\",volume:16874739,amount:211703678,ticktime:\"15:00:03\",per:43.929,pb:1.666,mktcap:1082688.62565,nmc:1014924.42876,turnoverratio:2.04507},{symbol:\"sz300077\",code:\"300077\",name:\"国民技术\",trade:\"7.620\",pricechange:\"-0.430\",changepercent:\"-5.342\",buy:\"7.610\",sell:\"7.620\",settlement:\"8.050\",open:\"7.880\",high:\"7.970\",low:\"7.580\",volume:26544318,amount:206938329,ticktime:\"15:00:03\",per:-3.372,pb:4.206,mktcap:424902.63,nmc:415333.2054,turnoverratio:4.87001},{symbol:\"sz300081\",code:\"300081\",name:\"恒信东方\",trade:\"11.780\",pricechange:\"-0.990\",changepercent:\"-7.753\",buy:\"11.780\",sell:\"11.790\",settlement:\"12.770\",open:\"12.500\",high:\"12.710\",low:\"11.700\",volume:19502688,amount:237793879,ticktime:\"15:00:03\",per:31.506,pb:2.345,mktcap:623347.977928,nmc:426251.092874,turnoverratio:5.38982},{symbol:\"sz300134\",code:\"300134\",name:\"大富科技\",trade:\"17.790\",pricechange:\"0.310\",changepercent:\"1.773\",buy:\"17.790\",sell:\"17.800\",settlement:\"17.480\",open:\"17.180\",high:\"18.570\",low:\"17.010\",volume:37910860,amount:683616896,ticktime:\"15:00:03\",per:593,pb:2.529,mktcap:1365378.952674,nmc:1267388.964174,turnoverratio:5.32145},{symbol:\"sz300250\",code:\"300250\",name:\"初灵信息\",trade:\"15.400\",pricechange:\"-1.250\",changepercent:\"-7.508\",buy:\"15.400\",sell:\"15.410\",settlement:\"16.650\",open:\"16.200\",high:\"16.500\",low:\"15.400\",volume:10535739,amount:168081821,ticktime:\"15:00:03\",per:-11.667,pb:3.311,mktcap:338784.44908,nmc:233956.60288,turnoverratio:6.93506},{symbol:\"sz300288\",code:\"300288\",name:\"朗玛信息\",trade:\"12.910\",pricechange:\"-1.010\",changepercent:\"-7.256\",buy:\"12.910\",sell:\"12.920\",settlement:\"13.920\",open:\"13.500\",high:\"13.610\",low:\"12.800\",volume:10506846,amount:139440161,ticktime:\"15:00:03\",per:41.645,pb:3.19,mktcap:436282.349982,nmc:261256.427008,turnoverratio:5.19196},{symbol:\"sz300292\",code:\"300292\",name:\"吴通控股\",trade:\"5.840\",pricechange:\"0.040\",changepercent:\"0.690\",buy:\"5.840\",sell:\"5.850\",settlement:\"5.800\",open:\"5.700\",high:\"6.280\",low:\"5.660\",volume:156249300,amount:937606869,ticktime:\"15:00:03\",per:-6.418,pb:4.63,mktcap:744512.677984,nmc:601296.24916,turnoverratio:15.17548},{symbol:\"sz300299\",code:\"300299\",name:\"富春股份\",trade:\"5.180\",pricechange:\"-0.030\",changepercent:\"-0.576\",buy:\"5.170\",sell:\"5.180\",settlement:\"5.210\",open:\"5.130\",high:\"5.510\",low:\"5.120\",volume:75962661,amount:404372610,ticktime:\"15:00:03\",per:64.75,pb:3.371,mktcap:368194.87915,nmc:321320.686708,turnoverratio:12.24592},{symbol:\"sz300310\",code:\"300310\",name:\"宜通世纪\",trade:\"6.370\",pricechange:\"0.230\",changepercent:\"3.746\",buy:\"6.370\",sell:\"6.380\",settlement:\"6.140\",open:\"5.910\",high:\"6.750\",low:\"5.880\",volume:140972682,amount:911757884,ticktime:\"15:00:03\",per:159.25,pb:3.196,mktcap:561616.484247,nmc:433170.991435,turnoverratio:20.73075},{symbol:\"sz300312\",code:\"300312\",name:\"邦讯技术\",trade:\"7.020\",pricechange:\"0.390\",changepercent:\"5.882\",buy:\"7.010\",sell:\"7.020\",settlement:\"6.630\",open:\"6.500\",high:\"7.290\",low:\"6.480\",volume:54081442,amount:383687450,ticktime:\"15:00:03\",per:-5.083,pb:11.433,mktcap:224668.08,nmc:141449.309586,turnoverratio:26.84013},{symbol:\"sz300565\",code:\"300565\",name:\"科信技术\",trade:\"11.940\",pricechange:\"0.190\",changepercent:\"1.617\",buy:\"11.930\",sell:\"11.940\",settlement:\"11.750\",open:\"11.430\",high:\"12.880\",low:\"11.380\",volume:17448272,amount:213151948,ticktime:\"15:00:03\",per:149.25,pb:3.537,mktcap:248352,nmc:180867.528348,turnoverratio:11.51851},{symbol:\"sz300597\",code:\"300597\",name:\"吉大通信\",trade:\"13.910\",pricechange:\"0.530\",changepercent:\"3.961\",buy:\"13.900\",sell:\"13.910\",settlement:\"13.380\",open:\"13.220\",high:\"14.680\",low:\"13.100\",volume:28506098,amount:396459452,ticktime:\"15:00:03\",per:77.278,pb:4.251,mktcap:333840,nmc:307078.05024,turnoverratio:12.91267},{symbol:\"sz300615\",code:\"300615\",name:\"欣天科技\",trade:\"19.830\",pricechange:\"0.230\",changepercent:\"1.173\",buy:\"19.820\",sell:\"19.830\",settlement:\"19.600\",open:\"19.380\",high:\"20.780\",low:\"19.120\",volume:6944337,amount:139636466,ticktime:\"15:00:03\",per:180.273,pb:7.932,mktcap:375958.87368,nmc:172717.689804,turnoverratio:7.97291}]'"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# from\n",
    "url_='http://vip.stock.finance.sina.com.cn/quotes_service/api/json_v2.php/Market_Center.getHQNodeData?page=1&num=10000&sort=symbol&asc=1&node=gn_5Ggn&symbol=&_s_r_a=setlen'\n",
    "js_obj=requests.get(url_)\n",
    "js_obj.encoding = js_obj.apparent_encoding\n",
    "js_obj.text\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-03-09T14:37:59.966291Z",
     "start_time": "2020-03-09T14:37:59.462638Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[('sh600050', '600050', '中国联通'),\n",
       " ('sh600105', '600105', '永鼎股份'),\n",
       " ('sh600198', '600198', '大唐电信'),\n",
       " ('sh600289', '600289', '*ST信通'),\n",
       " ('sh600345', '600345', '长江通信'),\n",
       " ('sh600485', '600485', '*ST信威'),\n",
       " ('sh600487', '600487', '亨通光电'),\n",
       " ('sh600498', '600498', '烽火通信'),\n",
       " ('sh600522', '600522', '中天科技'),\n",
       " ('sh600728', '600728', '佳都科技'),\n",
       " ('sh600770', '600770', '综艺股份'),\n",
       " ('sh603322', '603322', '超讯通信'),\n",
       " ('sh603602', '603602', '纵横通信'),\n",
       " ('sz000063', '000063', '中兴通讯'),\n",
       " ('sz002093', '002093', '国脉科技'),\n",
       " ('sz002104', '002104', '恒宝股份'),\n",
       " ('sz002115', '002115', '三维通信'),\n",
       " ('sz002148', '002148', '北纬科技'),\n",
       " ('sz002194', '002194', '武汉凡谷'),\n",
       " ('sz002261', '002261', '拓维信息'),\n",
       " ('sz002281', '002281', '光迅科技'),\n",
       " ('sz002313', '002313', '日海智能'),\n",
       " ('sz002316', '002316', '亚联发展'),\n",
       " ('sz002364', '002364', '中恒电气'),\n",
       " ('sz002369', '002369', '卓翼科技'),\n",
       " ('sz002417', '002417', '深南股份'),\n",
       " ('sz002446', '002446', '盛路通信'),\n",
       " ('sz002491', '002491', '通鼎互联'),\n",
       " ('sz002544', '002544', '杰赛科技'),\n",
       " ('sz002881', '002881', '美格智能'),\n",
       " ('sz300025', '300025', '华星创业'),\n",
       " ('sz300038', '300038', '数知科技'),\n",
       " ('sz300047', '300047', '天源迪科'),\n",
       " ('sz300050', '300050', '世纪鼎利'),\n",
       " ('sz300068', '300068', '南都电源'),\n",
       " ('sz300077', '300077', '国民技术'),\n",
       " ('sz300081', '300081', '恒信东方'),\n",
       " ('sz300134', '300134', '大富科技'),\n",
       " ('sz300250', '300250', '初灵信息'),\n",
       " ('sz300288', '300288', '朗玛信息'),\n",
       " ('sz300292', '300292', '吴通控股'),\n",
       " ('sz300299', '300299', '富春股份'),\n",
       " ('sz300310', '300310', '宜通世纪'),\n",
       " ('sz300312', '300312', '邦讯技术'),\n",
       " ('sz300565', '300565', '科信技术'),\n",
       " ('sz300597', '300597', '吉大通信'),\n",
       " ('sz300615', '300615', '欣天科技')]"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock_list = demjson.decode(js_obj.text)\n",
    "[(s['symbol'], s['code'], s['name']) for s in stock_list]"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  },
  "latex_envs": {
   "LaTeX_envs_menu_present": true,
   "autoclose": false,
   "autocomplete": true,
   "bibliofile": "biblio.bib",
   "cite_by": "apalike",
   "current_citInitial": 1,
   "eqLabelWithNumbers": true,
   "eqNumInitial": 1,
   "hotkeys": {
    "equation": "Ctrl-E",
    "itemize": "Ctrl-I"
   },
   "labels_anchors": false,
   "latex_user_defs": false,
   "report_style_numbering": false,
   "user_envs_cfg": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
